package com.song.JavaThread_day04.ch4_12;

import java.util.concurrent.TimeUnit;

public class Task implements Runnable{
	
	private String name;
	
	
	
	public Task(String name) {
		super();
		this.name = name;
	}



	@Override
	public void run() {
		
		try {
			System.out.println("Task "+name +"  :Starting");
			long duration =(long)(Math.random() *10);
			System.out.printf("Task %s : ReportGenerator : report during %d seconds \n" ,name,duration);
			TimeUnit.SECONDS.sleep(duration);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.printf(" Task %s : Ending\n" , name);	
	}



	@Override
	public String toString() {
		return name;
	}
	
	
}
